package com.lxf.education.controller;

import com.lxf.education.service.TeacherListService;
import com.lxf.education.utils.ResultVo;
//import org.bouncycastle.math.raw.Mod;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
/**
 * Created by Luoxingfa on 2022/5/1 0001 22:12
 */
@Controller
@RequestMapping("/tea") //此处的teacherlist与teacher页面中table的lay-filter值一一对应；
public class TeacherController {

    @Resource
    TeacherListService teacherService;

    /**
     *查询所有数据
     * @return
     */
    @RequestMapping("/findAll")
    @ResponseBody
    public ResultVo getAll(){
        ResultVo resultVo = teacherService.getAll();
        return resultVo;
    }

    /**
     * 分页查询
     * @param page 页码
     * @param limit 每行显示条数
     * @return
     */
    @RequestMapping("/findByPage")
    @ResponseBody
    public ResultVo getTeacherList(Integer page, Integer limit) {

        ResultVo resultVo = teacherService.getTeacherList(page,limit);
        return resultVo;
    }

    /**
     * 批量删除
     * @param ids
     * @return
     */
    @RequestMapping("/delAll")
    @ResponseBody
    public ResultVo delAll(Integer[] ids){

       return teacherService.delAllTea(ids);
    }

    /**
     * 根据id删除
     * @param id
     * @return
     */
    @RequestMapping("/delOne")
    @ResponseBody
    public ResultVo delTeaById(Integer id){
        return  teacherService.delTeacherById(id);
    }
    /**
     * 根据id更正信息
     * @return
     */
    @RequestMapping("/edit")
    @ResponseBody
    public ResultVo updateTeacher(Integer id,String value){

        return teacherService.updateTeacher(id,value);
    }

    /**
     * 单行查看
     * @param id
     * @param model
     * @return
     */
    @RequestMapping("/lookOne")
    public String lookOne(Integer id, Model model){
        teacherService.selById(id);
        return "teachers/detail_teacher";
    }
}
